using System;
using Sedge.Core.Utils;

namespace Sedge.Core.Configuration.Property
{
	public class CustomPropertyHandler : IPropertyHandler
	{
		private readonly string _assembly;
		private readonly string _className;
		private readonly Options _options;

		public CustomPropertyHandler(ReportableObject owner, string assembly, string className, Options options)
		{
			_assembly = PropertyResolver.ResolveValue(owner, assembly);
			_className = PropertyResolver.ResolveValue(owner, className);

			_options = options;
		}

		public string GetValue()
		{
			string result = String.Empty;
			ICustomProperty customProperty = TypeActivator.Activate<ICustomProperty>(_assembly, _className);
			if (customProperty != null)
				result = customProperty.GetValue(_options);

			return result;
		}
	}
}